package com.ruoyi.common.utils;

import cn.hutool.core.util.StrUtil;

import java.util.Objects;

/**
 * @author : hcl
 * @Date : 2023/8/2
 */
public class NumberUtils {
    /**
     * @param number >0 即真
     */
    public static boolean isTrue(Long number) {
        return Objects.nonNull(number) && number > 0;
    }

    /**
     * @param number >0 即真
     */
    public static boolean isTrue(Integer number) {
        return Objects.nonNull(number) && number > 0;
    }

    public static int toInt(String number) {
        if (Objects.isNull(number) || number.isEmpty()) {
            return 0;
        }
        return Integer.parseInt(number);
    }

    public static long toLong(String number) {
        if (Objects.isNull(number) || number.isEmpty()) {
            return 0L;
        }
        return Long.parseLong(number);
    }

    /**
     * long小于1
     */
    public static boolean isFalse(Long num) {
        return !isTrue(num);

    }

    public static boolean isFalse(Integer num) {
        return !isTrue(num);
    }
}
